package com.katian.analyse.picking;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;

/**
 * User: csavard
 * Date: 13-06-03
 */
public class CommandeVendue {
    public static final SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    private long noCommande;
    private Collection<Vente> ventes;

    public long getNoCommande() {
        return noCommande;
    }

    public void setNoCommande(long noCommande) {
        this.noCommande = noCommande;
    }

    public Collection<Vente> getVentes() {
        return ventes;
    }

    public void setVentes(Collection<Vente> ventes) {
        this.ventes = ventes;
    }

    public Date getDate() throws ParseException {
        Date date = null;
        if (ventes != null && ventes.size() > 0) {
            date = formatter.parse(ventes.iterator().next().getDate());
        }
        return date;
    }

    public String getNomDetaillant() {
        String nom = null;
        if (ventes != null && ventes.size() > 0) {
            nom = ventes.iterator().next().getNomDetaillant();
        }
        return nom;
    }

    public int getCaisses() {
        int nbCaisses = 0;
        if (ventes != null && ventes.size() > 0) {
            for (Vente vente : ventes) {
                nbCaisses += vente.getCaisses();
            }
        }
        return nbCaisses;
    }
}
